package Stream流;

import java.util.ArrayList;
import java.util.Map;
import java.util.stream.Collectors;

public class 数据过滤Num2 {
    /*创建一个ArrsyList集合，并存入"zhansan,23","lisi,24","wangwu,25"
    过滤年龄小于24的元素，并将剩下的元素存入Map集合当中，键是姓名值是年龄
     */
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        list.add("zhansan,23");
        list.add("lisi,24");
        list.add("wangwu,25");
        Map<String, Integer> collect = list.stream().filter(s -> Integer.parseInt(s.split(",")[1]) >= 24)
                .collect(Collectors.toMap(s -> s.split(",")[0], s -> Integer.parseInt(s.split(",")[1])));
        System.out.println(collect);
    }
}
